// import 'package:amap_search_fluttify/amap_search_fluttify.dart';

import 'package:date_format/date_format.dart';
import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:magic_car/UI/Loading.dart';
import 'package:magic_car/UI/update_dialog.dart';
import 'package:magic_car/common/nodata.dart';
import 'package:magic_car/jiance/jiance_detail.dart';
import 'package:magic_car/util/HttpHelper.dart';
import 'package:magic_car/util/colors.dart';
import 'package:package_info/package_info.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_cupertino_date_picker_fork/flutter_cupertino_date_picker_fork.dart';
import 'package:toast/toast.dart';

import 'package:url_launcher/url_launcher.dart';
import 'dart:io';
// import 'package:progress_dialog/progress_dialog.dart';
import 'package:flutter/cupertino.dart';

// import 'package:open_file/open_file.dart';
// import 'package:url_launcher/url_launcher.dart';
// import 'package:path_provider/path_provider.dart';
// import 'package:flutter_downloader/flutter_downloader.dart';
// import 'package:permission_handler/permission_handler.dart';
// import 'dart:io';
String apkName = 'flutterApp.apk';

//ProgressDialog pr;
class IOrderPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return new ActState();
  }
}

class ActState extends State<IOrderPage> with SingleTickerProviderStateMixin {
  List<Choice> _tabs = [];
  TabController mTabController;
  int mCurrentPosition = 0;
  int type = 1;
  List orders = [];
  Map userinfo = new Map();
  bool isInspector = true;
  bool endtest = false;
  bool isreview = false; //第一步初审

  bool loaddatas = false;
  bool noupdate = false;
  bool nohandeldata = false; //是否有待处理订单
  ScrollController _scrocontroller = new ScrollController();
  bool hasmore = false;
  int page = 1;
  List items = [
    {
      'title': '月份',
      'select': false,
      'value': '',
      'code': 'online',
      'option': '全部,合格,不合格',
      'type': 1,
      'value_des': ''
    },
    {
      'title': '日期',
      'select': false,
      'value': '',
      'code': 'underline',
      'option': '全部,合格,不合格',
      'type': 2,
      'value_des': ''
    },
    {
      'title': '检测类型',
      'select': false,
      'value': '',
      'code': 'inspector',
      'option': '全部,是,否',
      'type': 3,
      'value_des': ''
    },
    // {
    //   'title': '站点',
    //   'select': false,
    //   'value': '',
    //   'code': 'site',
    //   'type': 2,
    //   'value_des': ''
    // },
  ];
  String _format = 'yyyy-MMMM';
  String total_num = '0';
  String MIN_DATETIME = '1900-01-01';
  String MAX_DATETIME = '2025-01-01';
  String INIT_DATETIME = '2020-05-01';
  DateTime _dateTime;
  DateTimePickerLocale _locale = DateTimePickerLocale.zh_cn;
  List inspecttype = [
    {
      'title': '全车检测',
      'select': false,
      'value': '',
      'code': 'online',
      'option': '全部,合格,不合格',
      'type': 1,
      'value_des': ''
    },
    {
      'title': '事故检测',
      'select': false,
      'value': '',
      'code': 'underline',
      'option': '全部,合格,不合格',
      'type': 2,
      'value_des': ''
    },
    {
      'title': '金融检测',
      'select': false,
      'value': '',
      'code': 'inspector',
      'option': '全部,是,否',
      'type': 3,
      'value_des': ''
    },
    {
      'title': '保修检测',
      'select': false,
      'value': '',
      'code': 'inspector',
      'option': '全部,是,否',
      'type': 3,
      'value_des': ''
    },
    {
      'title': '认证检测',
      'select': false,
      'value': '',
      'code': 'inspector',
      'option': '全部,是,否',
      'type': 3,
      'value_des': ''
    },
  ];
  @override
  @override
  Widget build(BuildContext context) {
    if (isInspector == true) {
      return new Scaffold(
        appBar: new AppBar(
          
          title:
          Center(child:
           new Text(
            '订单',
            style: TextStyle(color: Colors.black),
          )),
          backgroundColor: Colors.white,
          elevation: 0,
          bottom: new TabBar(
            indicatorSize: TabBarIndicatorSize.label,
            indicatorColor: Color.fromRGBO(27, 182, 251, 1),
            labelColor: Color.fromRGBO(27, 182, 251, 1),
            unselectedLabelColor: Colors.black45,
            tabs: _tabs.map((Choice choice) {
              return new Tab(
                text: choice.title,
              );
            }).toList(),
            controller: mTabController,
          ),
        ),
        body: new TabBarView(
          children: _tabs.map((Choice choice) {
            return new Padding(
                padding: const EdgeInsets.all(0.0),
                child: new Container(
                  // color: Color.fromRGBO(239, 239, 239, 1),
                  child: Stack(children: <Widget>[
                    type != 2
                        ? new Container(height: 0)
                        : Align(
                            alignment: Alignment.topLeft,
                            child: Padding(
                                padding: new EdgeInsets.fromLTRB(10, 10, 10, 5),
                                child: new Container(
                                    child: new Column(
                                        mainAxisAlignment:
                                            MainAxisAlignment.start,
                                        crossAxisAlignment:
                                            CrossAxisAlignment.start,
                                        children: <Widget>[
                                      // new Container(
                                      //   child: new TextField(
                                      //     onSubmitted: (value) {

                                      //     },
                                      //     // controller: _phonecontroller,
                                      //     decoration: new InputDecoration(
                                      //         border: InputBorder.none,
                                      //         hintText: '搜索',
                                      //         prefixIcon:
                                      //             Icon(Icons.search)),
                                      //   ),
                                      //   decoration: new BoxDecoration(
                                      //     color: Colors.white,
                                      //     //设置四周圆角 角度 这里的角度应该为 父Container height 的一半
                                      //     borderRadius: BorderRadius.all(
                                      //         Radius.circular(25.0)),
                                      //     //设置四周边框
                                      //     border: new Border.all(
                                      //         width: 1,
                                      //         color: Colors.white),
                                      //   ),
                                      // ),
                                      new Container(
                                        child: filter(),
                                      )
                                    ])))),
                    type != 2
                        ? new Container(height: 0)
                        : Align(
                            alignment: Alignment.topLeft,
                            child: Padding(
                                padding: new EdgeInsets.fromLTRB(20, 50, 10, 5),
                                child: new Container(
                                    child: new Column(
                                        mainAxisAlignment:
                                            MainAxisAlignment.start,
                                        crossAxisAlignment:
                                            CrossAxisAlignment.start,
                                        children: <Widget>[
                                      new Container(
                                        child: new Text(
                                          '总计：' + total_num + '单',
                                          style: TextStyle(fontSize: 14),
                                        ),
                                      )
                                    ])))),
                    Align(
                        alignment: Alignment.bottomCenter,
                        child: Padding(
                            padding: new EdgeInsets.fromLTRB(
                                0, type != 2 ? 0 : 75, 0, 10),
                            child: new ListView(
                              controller: _scrocontroller,
                              children: <Widget>[buildcontent()],
                            )))
                  ]),
                  // Stack(children: <Widget>[
                ));
          }).toList(),
          controller: mTabController,
        ),
      );
      // new MaterialApp(

      //   debugShowCheckedModeBanner: false,

      // home:
      //     new Scaffold(
      //   appBar: new AppBar(
      //     title: new Text(
      //       '订单',
      //       style: TextStyle(color: Colors.black),
      //     ),
      //     backgroundColor: Colors.white,
      //     elevation: 0,
      //     bottom: new TabBar(
      //       indicatorSize: TabBarIndicatorSize.label,
      //       indicatorColor: Colours.app_main,
      //       labelColor: Colours.app_main,
      //       unselectedLabelColor: Colors.black45,
      //       tabs: _tabs.map((Choice choice) {
      //         return new Tab(
      //           text: choice.title,
      //         );
      //       }).toList(),
      //       controller: mTabController,
      //     ),
      //   ),
      //   body: new TabBarView(
      //     children: _tabs.map((Choice choice) {
      //       return new Padding(
      //           padding: const EdgeInsets.all(0.0),
      //           child: new Container(
      //               color: Color.fromRGBO(239, 239, 239, 1),
      //               child: new RefreshIndicator(
      //                   onRefresh: _handlerRefresh,
      //                   child: new ListView(
      //                     children: <Widget>[buildcontent()],
      //                   ))));
      //     }).toList(),
      //     //           orders.length == 0
      //     //               ? Nodata()
      //     //               : new ListView(
      //     //                   children: <Widget>[buildcontent()],
      //     //                 )));
      //     // }).toList(),
      //     controller: mTabController,
      //   ),
      // );
    } else {
      return
          // new MaterialApp(
          //   debugShowCheckedModeBanner: false,
          //   home:
          new Scaffold(
        appBar: new AppBar(
          title: 
          Center(child:
           new Text(
            '订单',
            style: TextStyle(color: Colors.black),
          )),
          backgroundColor: Colors.white,
          elevation: 0,
        ),
        body: new Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              isreview == false ? Text('您的账号未审核，请耐心等待') : Text('账号信息已审核'),
              userinfo["status"] == "2"
                  ? Text(
                      '审核未通过：' + userinfo["failreason"] + ' 如有疑问，请联系客服',
                      style: TextStyle(color: Colors.red),
                    )
                  : new Text(""),
              Padding(
                padding: new EdgeInsets.fromLTRB(0, 10, 0, 0),
                child: endtest == false &&
                        isreview == true &&
                        userinfo["status"].toString() == '1'
                    ? FlatButton(
                        onPressed: () {
                          Navigator.pushNamed(context, "exam");
                        },
                        child: new Text('去考试'),
                        color: Color.fromRGBO(27, 182, 251, 1),
                      )
                    : new Text(""),
              ),
              // userinfo["failreason"]!=""?
              // Padding(padding: new EdgeInsets.fromLTRB(0, 10, 0, 0),child:
              // FlatButton(onPressed: (){
              // Navigator.pushNamed(context, "exam");
              // }, child:
              // new Text(''),
              // color: Color.fromRGBO(27, 182, 251, 1),
              // ) ):new Text(''),
            ],
          ),
        ),
      );
    }
  }

  @override
  deactivate() async {
    var bool = ModalRoute.of(context).isCurrent;
    if (bool) {
      print('页面出现时');
      loaduserinfo();
    }
  }

  void didChangeDependencies() {
    ///在initState之后调 Called when a dependency of this [State] object changes.
    super.didChangeDependencies();
  }

//检查更新

  void _showUpdateDialog(content, url) {
    showDialog<void>(
        context: context,
        barrierDismissible: false,
        builder: (_) => UpdateDialog(content, url));
  }

  @override
  void initState() {
    super.initState();

//checkUpdate(context);
    _tabs.add(Choice(title: '待处理', position: 0));
    _tabs.add(Choice(title: '进行中', position: 1));
    // _tabs.add(Choice(title: '待评价', position: 1));
    _tabs.add(Choice(title: '已完成', position: 3));
    // mTabController = new TabController(vsync: this, length: _tabs.length);
    mTabController = new TabController(vsync: this, length: _tabs.length);
    //判断TabBar是否切换
    mTabController.addListener(() {
      if (mTabController.index == mCurrentPosition) return;
      print('滑动监听' + mTabController.index.toString());
      setState(() {
        mCurrentPosition = mTabController.index;
        // mTabController.animateTo(value)
        // if(mCurrentPosition==0){
        //   type=1;
        // }else
        type = mTabController.index + 1;
        // orders = [];
      });
      // mTabController.animateTo(mTabController.index);
      items[0]['value'] = '';
      items[1]['value'] = '';
      items[2]['value'] = '';
      setState(() {
        orders = [];
        items = items;
        page = 1;
      });
      loaddata();

      // if(type>1){
      // loaddata();
      // }//滑动时加载数据
    });
    _scrocontroller.addListener(() {
      if (_scrocontroller.position.pixels ==
          _scrocontroller.position.maxScrollExtent) {
        type = mCurrentPosition + 1;
        print('滑动到了最底部');
        print(type.toString());

        // setState(() {
        //   type = mCurrentPosition + 1;
        // });
        if (hasmore)
          loaddata();
        else {
          if (type == 2) {
            type = -1;
          }
          if (type == 3) {
            type = 2;
          }
        }
      }
    });
    //loading();

    // loaddata(); //页面展示时加载数据
    loaduserinfo();
    // if (Platform.isAndroid) {
    //   checkversion();//安卓版本检查更新
    // }
    checkversion();
  }

  // ///2.显示更新内容
  // showUpdate(
  //     BuildContext context, String version, String data, String url) async {
  //   showDialog<void>(
  //     context: context,
  //     barrierDismissible: true,
  //     builder: (BuildContext context) {
  //       return CupertinoAlertDialog(
  //         title: Text('检测到新版本 v$version'),
  //         content: Text('是否要更新到最新版本?'),
  //         actions: <Widget>[
  //           FlatButton(
  //             child: Text('下次在说'),
  //             onPressed: () {
  //               Navigator.of(context).pop();
  //             },
  //           ),
  //           FlatButton(
  //             child: Text('立即更新'),
  //             onPressed: () {},
  //           ),
  //         ],
  //       );
  //     },
  //   );
  // }
  Future<Null> _handlerRefresh() async {
    //模拟耗时5秒
    // loaddata();
    return null;
  }

  void _showDatePicker(item) {
    print('选择日期');
    DatePicker.showDatePicker(
      context,
      onMonthChangeStartWithFirstDate: true,
      pickerTheme: DateTimePickerTheme(
        showTitle: true,
        confirm: Text('确定', style: TextStyle(color: Colors.red)),
        cancel: Text('不限', style: TextStyle(color: Colors.cyan)),
      ),
      minDateTime: DateTime.parse(MIN_DATETIME),
     // maxDateTime: DateTime.parse(MAX_DATETIME),
      initialDateTime: _dateTime,
      dateFormat: _format,
      locale: _locale,
      onClose: () => print("----- onClose -----"),
      onCancel: () {
        //不限
        setState(() {
          item['value_des'] = item['type'] == 1 ? '月份' : '日期';
          item['value'] = '';
          item['select'] = false;
        });
        page = 1;
        type = 3;
        loaddata();
      },
      onChange: (dateTime, List<int> index) {
        print(dateTime);
        setState(() {
          //_dateTime = dateTime;
        });
      },
      onConfirm: (dateTime, List<int> index) {
        print(dateTime);
        print(item);
        setState(() {
          //  String code = item["code"];
          if (item['type'] == 2) {
            item["value"] = formatDate(dateTime, [yyyy, "-", mm, '-', dd]);

            item['value_des'] = formatDate(dateTime, [yyyy, "-", mm, '-', dd]);
          } else {
            item["value"] = formatDate(dateTime, [yyyy, "-", mm]);

            item['value_des'] = formatDate(dateTime, [yyyy, "-", mm]);
          }

          for (int i = 0; i < items.length - 1; i++) {
            if (item != items[i]) {
              items[i]['select'] = false;
              items[i]['value'] = "";
              items[i]['value_des'] = i == 0 ? '月份' : '日期';
            }
          }
          item['select'] = true;
          // item['value']=dateTime;
          //formalities[code] = item["value"];
        });
        setState(() {
          // _dateTime = dateTime;
        });
        page = 1;
        type = 3;
        loaddata();
        //saveResult();
      },
    );
  }

  Widget filter() {
    List<Widget> tiles = [];
    Widget content;

    for (var i = 0; i < items.length; i++) {
      var radios = items[i]['title'];
      bool checkvalue = false;

      //  bool has = RegExp(item['value']).hasMatch(radios);
      if (radios != "") {
        tiles.add(Padding(
            padding: new EdgeInsets.fromLTRB(10, 5, 0, 5),
            child: GestureDetector(
                // key: _myKey,
                onTap: () {
                  if (items[i]['type'] == 2 || items[i]['type'] == 1) {
                    if (items[i]['type'] == 2) {
                      _format = 'yyyy-MMMM-dd';
                    } else {
                      _format = 'yyyy-MMMM';
                    }

                    _showDatePicker(items[i]);
                  } else {
                    showtypeView();
                    //showSiteView();
                  }

                  //showSiteView();
                },
                child: Container(
                  width: 100,
                  padding: EdgeInsets.symmetric(vertical: 8, horizontal: 10),
                  child: Center(
                      child: Text(
                    items[i]['value_des'] == ""
                        ? radios
                        : items[i]['value_des'],
                    style: new TextStyle(
                        fontSize: 10,
                        color: items[i]['select'] == false
                            ? Color.fromRGBO(120, 120, 120, 1)
                            : Colors.white),
                  )),
                  decoration: new BoxDecoration(
                    color: items[i]['select'] == false
                        ? Color.fromRGBO(225, 225, 225, 1)
                        : Colors.blue,
                    borderRadius:
                        new BorderRadius.all(new Radius.circular(10.0)),
                  ),
                ))));
      }

      // tiles.add(

    }
    content = new Container(
        child: new Wrap(
      spacing: 0,
      runSpacing: 0,
      children: tiles,
    ));
    return content;
  }

  //检测类型筛选组件
  showtypeView() {
    showModalBottomSheet(
        context: context,
        builder: (BuildContext context) {
          return showType();
        });
  }

  Widget showType() {
    return new Container(
      height: 260.0,
      child: new Column(
        children: <Widget>[
          new Padding(
            padding: EdgeInsets.fromLTRB(0.0, 10.0, 0.0, 0.0),
            child: new Container(
                height: 200.0,
                child: new ListView(children: <Widget>[typeView()])),
          ),
          new Container(
            height: 0.5,
            color: Colors.blueGrey,
          ),
          new Center(
            child: new Padding(
              padding: EdgeInsets.fromLTRB(0.0, 12.0, 0.0, 8.0),
              child: GestureDetector(
                  behavior: HitTestBehavior.opaque,
                  onTap: () {
                    Navigator.of(context).pop();
                    List temp = items;
                    temp[2]['value'] = "";
                    temp[2]['value_des'] = "检测类型";
                    temp[2]['select'] = false;

                    setState(() {
                      items = temp;
                    });

                    type = 3;

                    page = 1;
                    loaddata();
                  },
                  child: new Text(
                    '不限',
                    style:
                        new TextStyle(fontSize: 18.0, color: Colors.blueGrey),
                  )),
            ),
          ),
        ],
      ),
    );
  }

  Widget typeView() {
    List<Widget> tiles = [];
    Widget content;
    for (var item in inspecttype) {
      tiles.add(GestureDetector(
          onTap: () {
            // time_str = item;
            Navigator.of(context).pop();
            List temp = items;
            temp[2]['value'] = item['title'].toString();
            temp[2]['value_des'] = item['title'];
            temp[2]['select'] = true;
            setState(() {
              items = temp;
            });
            type = 3;
            page = 1;
            loaddata();
          },
          child: Container(
              height: 40, child: Center(child: new Text(item['title'])))));
    }

    content = new Column(
        children: tiles //重点在这里，因为用编辑器写Column生成的children后面会跟一个<Widget>[]，
        //此时如果我们直接把生成的tiles放在<Widget>[]中是会报一个类型不匹配的错误，把<Widget>[]删了就可以了
        );
    return content;
  }

  showupdates(param) {
    showModalBottomSheet(
      context: context,
      builder: (BuildContext context) {
        return new Container(
          height: 300.0,
          child: new ListView(
            children: <Widget>[
              Container(
                  height: 40,
                  child: Padding(
                      padding: new EdgeInsets.fromLTRB(0, 0, 0, 0),
                      child: Center(child: Text('版本更新')))),
              Container(
                  height: 40,
                  child: Padding(
                      padding: new EdgeInsets.fromLTRB(0, 0, 0, 0),
                      child: Center(child: Text('新版本更新内容')))),
              Container(
                  height: 130,
                  child: Padding(
                      padding: new EdgeInsets.fromLTRB(0, 0, 0, 0),
                      child: Center(child: Text(param["ModifyContent"])))),
              Padding(
                  padding: new EdgeInsets.fromLTRB(0, 10, 0, 0),
                  child: Container(
                    height: 40,
                    child: GestureDetector(
                      behavior: HitTestBehavior.opaque,
                      onTap: () {
                        launch(param["DownloadUrl"]);
                        Navigator.pop(context);
                      },
                      child: Center(
                          child: Text('立即更新',
                              style: TextStyle(color: Colors.white))),
                    ),
                    decoration: new BoxDecoration(
                      border: new Border.all(
                          width: 1.0, color: Color.fromRGBO(225, 225, 225, 1)),
                      color: Colors.blue,
                    ),
                  )),
              Container(
                height: 40,
                child: GestureDetector(
                  behavior: HitTestBehavior.opaque,
                  onTap: () {
                    Navigator.pop(context);
                  },
                  child: Center(
                      child: Text(
                    '暂不更新',
                    style: TextStyle(color: Colors.black),
                  )),
                ),
                decoration: new BoxDecoration(
                  border: new Border.all(
                      width: 1.0, color: Color.fromRGBO(225, 225, 225, 1)),
                  color: Color.fromRGBO(225, 225, 225, 1),
                ),
              )
            ],
          ),
        );
      },
    ).then((val) {
      print(val);
    });
  }

  checkversion() {
    if (Platform.isAndroid) {
      //SharedPreferences pref = await SharedPreferences.getInstance();
      Map<String, String> map = new Map();
      // map["id"] = pref.getString('uid');

      HttpHelper.post(HttpHelper.API_Version, (data) async {
        //loadpage.close();
        if (data != null) {
          print(data);

          PackageInfo packageInfo = await PackageInfo.fromPlatform();
          String localVersion = packageInfo.version;
          String romot_version = data['VersionName'];
          if (localVersion != romot_version) {
            SpUtil.putString("versionmodify", data['ModifyContent']);
            SpUtil.putString("app_down", data['DownloadUrl']);
            // showupdates(data);
            Future.delayed(Duration(seconds: 3), () {
              _showUpdateDialog(data['ModifyContent'], data['DownloadUrl']);
            });
          }
        }
      }, params: map);
    }
  }

  loaduserinfo() async {
    // LoadingPage loadpage = new LoadingPage(context);
    // loadpage.show();
    SharedPreferences pref = await SharedPreferences.getInstance();
    Map<String, String> map = new Map();
    map["id"] = pref.getString('uid');

    HttpHelper.post(HttpHelper.API_Userinfo, (data) async {
      //loadpage.close();
      if (data != null) {
        if (data["code"].toString() == "1") {
          if (data["info"]["avatar"].length != 0) {
            setState(() {
              // avatar = data["info"]["avatar"];
            });
          }
          var info = data["info"];
          if (info["isInspector"].toString() == "1") {
            //最终通过审核
            setState(() {
              isInspector = true;
            });
            if (loaddatas == false) loaddata(); //获取订单数据
          } else {
            setState(() {
              isInspector = false;
            });
            if (info['is_review'].toString() == '1') {
              setState(() {
                isreview = true;
              });
            }
            if (info["starttest"].toString() == "1") {
              //考试结束
              setState(() {
                endtest = true;
              });
            }
          }
          setState(() {
            userinfo = data["info"];
          });
          //pref.setStringList('userinfo', data["info"]);

        }
      }
    }, params: map);
  }

  //加载数据
  loaddata() async {
    EasyLoading.show(status: "加载中...");
    // Toast.show('数据正在加载中...', context);
    // LoadingPage loadpage = new LoadingPage(context);
    // loadpage.show();
    Map<String, String> map = new Map();
    SharedPreferences pref = await SharedPreferences.getInstance();
    // print(pref.getStringList('userinfo'));
    map["id"] = pref.getString('uid');
    if (type == 2) {
      type = -1;
    }
    if (type == 3) {
      type = 2;
    }
    map["type"] = type.toString();
    map["month"] = items[0]['value'];
    map["day"] = items[1]['value'];
    map["test_type"] = items[2]['value'];
    map["page"] = this.page.toString();
    print('请求参数');
    print(map);

    HttpHelper.post(HttpHelper.API_UserOrderList, (data) async {
      if (data != null) {
        //Toast.show(data["msg"],context);
        print(data["info"].length.toString());
        if (data["code"].toString() == "1") {
           if (this.page == 1) {
           
              orders.clear();
            }
          Future.delayed(Duration(seconds: 1), () {
            EasyLoading.dismiss();
            //loadpage.close();
           
            orders.addAll(data["info"]);
            setState(() {
              // orders = data["info"];
              loaddatas = true;
              orders = orders;
              
            });
          });

          if (data["info"].length == 0) {
            setState(() {
              total_num = "0";
              // orders = [];
              // loaddatas = true;
            });
          } else {
            setState(() {
              total_num = data["info"][0]['total_num'].toString();
            });
          }

          if (data["info"].length == 10) {
            //有更多数据
            setState(() {
              hasmore = true;
              page++;
            });
          } else {
            setState(() {
              hasmore = false;
            });
          }
        }
      }
    }, params: map);
  }

  @override
  void dispose() {
    super.dispose();
    mTabController.dispose();
  }

//MediaQuery.of(context).size.height
  Widget buildcontent() {
    List<Widget> tiles = [];
    Widget content;
    if (orders.length == 0) {
      tiles.add(
          //Nodata()
          Center(
              child: Column(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
            Padding(
                padding: new EdgeInsets.fromLTRB(
                    15, MediaQuery.of(context).size.height / 2 - 100, 15, 0),
                child: new Text('暂无订单数据'))
          ])));
    } else {
      for (var i = 0; i < orders.length; i++) {
        var order = orders[i];
        tiles.add(Padding(
            padding: new EdgeInsets.fromLTRB(15, 10, 15, 0),
            child: 
            GestureDetector(
              onTap: (){
                 Navigator.of(context).push(
                                        new MaterialPageRoute(builder: (_) {
                                      return new JIanceDetailPage(
                                          order["id"].toString());
                                    }));
              },
              child:
            Container(
              decoration: new BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.all(Radius.circular(10.0)),
              ),
              child: Column(
                children: <Widget>[
                  Padding(
                    padding: new EdgeInsets.fromLTRB(20, 10, 20, 10),
                    child: Row(
                      children: <Widget>[
                        Expanded(
                            flex: 2,
                            child: new Text(
                              order["order_sn"],
                              style: TextStyle(
                                  color: Color.fromRGBO(51, 51, 51, 1),
                                  fontSize: 13),
                            )),
                        Expanded(
                          flex: 1,
                          child: new Align(
                              alignment: Alignment.centerRight,
                              child: Container(
                                  padding: new EdgeInsets.fromLTRB(5, 2, 5, 2),
                                  color: Colours.app_main,
                                  child: new Text(
                                    order["test_type"],
                                    style: TextStyle(
                                        color: Colors.white, fontSize: 12),
                                  ))),
                        )
                      ],
                    ),
                  ),
                  Padding(
                    padding: new EdgeInsets.fromLTRB(20, 10, 20, 10),
                    child: Row(
                      children: <Widget>[
                        Expanded(
                            flex: 1,
                            child: new Text(
                              '联系电话',
                              style: TextStyle(
                                  fontSize: 12,
                                  color: Color.fromRGBO(51, 51, 51, 1)),
                            )),
                        Expanded(
                          flex: 1,
                          child: new Align(
                              alignment: Alignment.centerRight,
                              child: Container(
                                  child: new Text(
                                order["phone_num"],
                                style: TextStyle(
                                    color: Color.fromRGBO(153, 153, 153, 1),
                                    fontSize: 12),
                              ))),
                        )
                      ],
                    ),
                  ),
                  Padding(
                    padding: new EdgeInsets.fromLTRB(20, 0, 20, 10),
                    child: Row(
                      children: <Widget>[
                        Expanded(
                            flex: 1,
                            child: new Text(
                              '预约时间',
                              style: TextStyle(
                                  fontSize: 12,
                                  color: Color.fromRGBO(51, 51, 51, 1)),
                            )),
                        Expanded(
                          flex: 1,
                          child: new Align(
                              alignment: Alignment.centerRight,
                              child: Container(
                                  child: new Text(
                                order['order_time'],
                                style: TextStyle(
                                    color: Color.fromRGBO(153, 153, 153, 1),
                                    fontSize: 12),
                              ))),
                        )
                      ],
                    ),
                  ),
                  Padding(
                    padding: new EdgeInsets.fromLTRB(20, 0, 20, 10),
                    child: Row(
                      children: <Widget>[
                        Expanded(
                            flex: 1,
                            child: new Text(
                              '订单金额',
                              style: TextStyle(
                                  fontSize: 12,
                                  color: Color.fromRGBO(51, 51, 51, 1)),
                            )),
                        Expanded(
                          flex: 1,
                          child: new Align(
                              alignment: Alignment.centerRight,
                              child: Container(
                                  child: new Text(
                                '¥' + order['orderPrice'],
                                style: TextStyle(
                                    color: Color.fromRGBO(251, 73, 57, 1),
                                    fontSize: 12),
                              ))),
                        )
                      ],
                    ),
                  ),
                  Padding(
                    padding: new EdgeInsets.fromLTRB(20, 0, 20, 10),
                    child: Row(
                      children: <Widget>[
                        Expanded(
                            flex: 1,
                            child: new Text(
                              '汽车品牌',
                              style: TextStyle(
                                  fontSize: 12,
                                  color: Color.fromRGBO(51, 51, 51, 1)),
                            )),
                        Expanded(
                          flex: 1,
                          child: new Align(
                              alignment: Alignment.centerRight,
                              child: Container(
                                  child: new Text(
                                order["brand_id"] != "0"
                                    ? order["brand_string"]["name"]
                                    : '暂无',
                                style: TextStyle(
                                    color: Color.fromRGBO(153, 153, 153, 1),
                                    fontSize: 12),
                              ))),
                        )
                      ],
                    ),
                  ),
                  order['test_type'] == "认证检测"
                      ? Padding(
                          padding: new EdgeInsets.fromLTRB(20, 0, 20, 10),
                          child: Row(
                            children: <Widget>[
                              Expanded(
                                  flex: 1,
                                  child: new Text(
                                    '车架号',
                                    style: TextStyle(
                                        fontSize: 12,
                                        color: Color.fromRGBO(51, 51, 51, 1)),
                                  )),
                              Expanded(
                                flex: 1,
                                child: new Align(
                                    alignment: Alignment.centerRight,
                                    child: Container(
                                        child: new Text(
                                      "${order['chejia_temp']}",
                                      style: TextStyle(
                                          color:
                                              Color.fromRGBO(153, 153, 153, 1),
                                          fontSize: 12),
                                    ))),
                              )
                            ],
                          ),
                        )
                      : Container(height: 0),
                  order['test_type'] == "认证检测"
                      ? Padding(
                          padding: new EdgeInsets.fromLTRB(20, 0, 20, 10),
                          child: Row(
                            children: <Widget>[
                              Expanded(
                                  flex: 1,
                                  child: new Text(
                                    '商家地址',
                                    style: TextStyle(
                                        fontSize: 12,
                                        color: Color.fromRGBO(51, 51, 51, 1)),
                                  )),
                              Expanded(
                                flex: 1,
                                child: new Align(
                                    alignment: Alignment.centerRight,
                                    child: Container(
                                        child: new Text(
                                      "${order['address']}",
                                      style: TextStyle(
                                          color:
                                              Color.fromRGBO(153, 153, 153, 1),
                                          fontSize: 12),
                                    ))),
                              )
                            ],
                          ),
                        )
                      : Container(height: 0),
                  int.parse(order['status']) > 1
                      ? Padding(
                          padding: new EdgeInsets.fromLTRB(20, 0, 20, 10),
                          child: Row(
                            children: <Widget>[
                              Expanded(
                                  flex: 1,
                                  child: new Text(
                                    '完成时间',
                                    style: TextStyle(
                                        fontSize: 12,
                                        color: Color.fromRGBO(51, 51, 51, 1)),
                                  )),
                              Expanded(
                                flex: 1,
                                child: new Align(
                                    alignment: Alignment.centerRight,
                                    child: Container(
                                        child: new Text(
                                      "${order['overtime']}",
                                      style: TextStyle(
                                          color:
                                              Color.fromRGBO(153, 153, 153, 1),
                                          fontSize: 12),
                                    ))),
                              )
                            ],
                          ),
                        )
                      : Container(height: 0),
                  Padding(
                    padding: new EdgeInsets.fromLTRB(20, 10, 20, 10),
                    child: Align(
                        alignment: Alignment.centerRight,
                        child: new Container(
                          child: new Material(
                            //INK可以实现装饰容器
                            child: new Ink(
                              //用ink圆角矩形
                              // color: Colors.red,
                              decoration: new BoxDecoration(
                                  //背景
                                  color: Colors.white,
                                  //设置四周圆角 角度
                                  borderRadius:
                                      BorderRadius.all(Radius.circular(15.0)),
                                  //设置四周边框
                                  border: new Border.all(
                                      width: 1, color: Colours.app_main)),
                              child: new InkWell(
                                  //圆角设置,给水波纹也设置同样的圆角
                                  //如果这里不设置就会出现矩形的水波纹效果
                                  borderRadius: new BorderRadius.circular(15.0),
                                  //设置点击事件回调
                                  onTap: () {
                                    Navigator.of(context).push(
                                        new MaterialPageRoute(builder: (_) {
                                      return new JIanceDetailPage(
                                          order["id"].toString());
                                    }));
                                  },
                                  child: Container(
                                    //设置 child 居中
                                    alignment: Alignment(0, 0),
                                    height: 30,
                                    width: 85,
                                    child: Text(
                                      "查看订单",
                                      style: TextStyle(color: Colours.app_main),
                                    ),
                                  )),
                            ),
                          ),
                        )
                        // child: new RaisedButton(
                        //   child: Text('申请补考'),
                        //   onPressed: () {},
                        // ),
                        ),
                  ),
                ],
              ),
            ))));
      }
    }
    content = new Column(
        children: tiles //重点在这里，因为用编辑器写Column生成的children后面会跟一个<Widget>[]，
        //此时如果我们直接把生成的tiles放在<Widget>[]中是会报一个类型不匹配的错误，把<Widget>[]删了就可以了
        );
    return content;
  }
}

Widget buttons() {
  Widget button = Container(
    margin: EdgeInsets.only(left: 40, top: 40),
    child: new Material(
      //INK可以实现装饰容器
      child: new Ink(
        //用ink圆角矩形
        // color: Colors.red,
        decoration: new BoxDecoration(
          //背景
          color: Colors.white,
          //设置四周圆角 角度
          borderRadius: BorderRadius.all(Radius.circular(25.0)),
          //设置四周边框
          border: new Border.all(width: 1, color: Colors.red),
        ),
        child: new InkWell(
            //圆角设置,给水波纹也设置同样的圆角
            //如果这里不设置就会出现矩形的水波纹效果
            borderRadius: new BorderRadius.circular(25.0),
            //设置点击事件回调
            onTap: () {},
            child: Container(
              //设置 child 居中
              alignment: Alignment(0, 0),
              height: 50,
              width: 300,
              child: Text("点击 Container 圆角边框"),
            )),
      ),
    ),
  );
  return button;
}

class Choice {
  const Choice({this.title, this.icon, this.position});
  final String title;
  final int position;
  final IconData icon;
}

// import 'package:flutter/material.dart';
// import 'package:magic_car/UI/Loading.dart';
// import 'package:magic_car/jiance/jiance_detail.dart';
// import 'package:magic_car/util/HttpHelper.dart';
// import 'package:shared_preferences/shared_preferences.dart';

// import 'package:toast/toast.dart';

// class IOrderPage extends StatefulWidget {
//   @override
//   State<StatefulWidget> createState() {
//     return new ActState();
//   }
// }

// class ActState extends State<IOrderPage> with SingleTickerProviderStateMixin {
//   List<Choice> _tabs = [];
//   TabController mTabController;
//   int mCurrentPosition = 0;
//   int type = 1;
//   List orders = [];
//   Map userinfo = new Map();
//   bool isInspector = true;
//   bool endtest = false;
//   @override
//   @override
//   Widget build(BuildContext context) {
//     if (isInspector == true) {
//       return
//       // new MaterialApp(

//       //   debugShowCheckedModeBanner: false,

//       // home:
//      new Scaffold(
//         appBar: new AppBar(
//           title: new Text('订单',style: TextStyle(color:Colors.black),),
//           backgroundColor: Colors.white,
//           elevation: 0,
//           bottom: new TabBar(
//             indicatorSize: TabBarIndicatorSize.label,
//             indicatorColor: Color.fromRGBO(27, 182, 251, 1),
//             labelColor: Color.fromRGBO(27, 182, 251, 1),
//             unselectedLabelColor: Colors.black45,
//             tabs: _tabs.map((Choice choice) {
//               return new Tab(
//                 text: choice.title,
//               );
//             }).toList(),
//             controller: mTabController,
//           ),
//         ),

//         body: new TabBarView(
//           children: _tabs.map((Choice choice) {
//             return new Padding(
//                 padding: const EdgeInsets.all(0.0),
//                 child: new Container(
//                     color: Color.fromRGBO(239, 239, 239, 1),
//                     child: new ListView(
//                       children: <Widget>[buildcontent()],
//                     )));
//           }).toList(),
//           controller: mTabController,
//         ),
//       );
//     } else {
//       return
//       // new MaterialApp(
//       //   debugShowCheckedModeBanner: false,
//       //   home:
//       new Scaffold(
//         appBar: new AppBar(
//           title: new Text('订单',style: TextStyle(color:Colors.black),),
//           backgroundColor: Colors.white,
//           elevation: 0,
//         ),
//         body: new Center(
//           child: Column(
//             mainAxisAlignment: MainAxisAlignment.center,
//             crossAxisAlignment: CrossAxisAlignment.center,
//             children: <Widget>[
//               endtest == false
//                   ? Text('您的账号未审核，请先进行考试')
//                   : Text('您的账号正在审核，请耐心等待'),
//               userinfo["failreason"] != ""
//                   ? Text(
//                       '审核未通过：' + userinfo["failreason"],
//                       style: TextStyle(color: Colors.red),
//                     )
//                   : new Text(""),
//               Padding(
//                 padding: new EdgeInsets.fromLTRB(0, 10, 0, 0),
//                 child: endtest == false
//                     ? FlatButton(
//                         onPressed: () {
//                           Navigator.pushNamed(context, "exam");
//                         },
//                         child: new Text('去考试'),
//                         color: Color.fromRGBO(27, 182, 251, 1),
//                       )
//                     : new Text(""),
//               ),
//               // userinfo["failreason"]!=""?
//               // Padding(padding: new EdgeInsets.fromLTRB(0, 10, 0, 0),child:
//               // FlatButton(onPressed: (){
//               // Navigator.pushNamed(context, "exam");
//               // }, child:
//               // new Text(''),
//               // color: Color.fromRGBO(27, 182, 251, 1),
//               // ) ):new Text(''),
//             ],
//           ),
//         ),
//       );
//     }
//   }

// void didChangeDependencies() {
//     ///在initState之后调 Called when a dependency of this [State] object changes.
//     super.didChangeDependencies();
//   }
//   @override
//   deactivate() async {
//     var bool = ModalRoute.of(context).isCurrent;
//     if (bool) {
//       print('页面出现时');
//       loaduserinfo();
//     }
//   }

//   @override
//   void initState() {
//     super.initState();

//     _tabs.add(Choice(title: '待处理', position: 0));
//     _tabs.add(Choice(title: '进行中', position: 1));
//     //_tabs.add(Choice(title: '待评价', position: 2));
//     _tabs.add(Choice(title: '已完成', position: 3));
//     mTabController = new TabController(vsync: this, length: _tabs.length);
//     //判断TabBar是否切换
//     mTabController.addListener(() {
//       if (mTabController.index == mCurrentPosition) return;
//       print('滑动监听' + mTabController.index.toString());
//       setState(() {
//         mCurrentPosition = mTabController.index;
//         type = mTabController.index+1;
//       });
//       loaddata(); //滑动时加载数据
//     });
//     //loading();

//     // loaddata(); //页面展示时加载数据
//     loaduserinfo();
//   }

//   loaduserinfo() async {
//     // LoadingPage loadpage = new LoadingPage(context);
//     // loadpage.show();
//     SharedPreferences pref = await SharedPreferences.getInstance();
//     Map<String, String> map = new Map();
//     map["id"] = pref.getString('uid');

//     HttpHelper.post(HttpHelper.API_Userinfo, (data) async {
//       //loadpage.close();
//       if (data != null) {

//         if (data["code"].toString() == "1") {
//           if (data["info"]["avatar"].length != 0) {
//             setState(() {
//               // avatar = data["info"]["avatar"];
//             });
//           }
//           var info = data["info"];
//           if (info["isInspector"].toString() == "1") {
//             //最终通过审核
//             setState(() {
//               isInspector = true;
//             });
//             loaddata(); //获取订单数据
//           } else {
//             setState(() {
//               isInspector = false;
//             });
//             if (info["starttest"].toString() == "1") {
//               //考试结束
//               setState(() {
//                 endtest = true;
//               });
//             }
//           }
//           setState(() {
//             userinfo = data["info"];
//           });
//           //pref.setStringList('userinfo', data["info"]);

//         }
//       }
//     }, params: map);
//   }

//   //加载数据
//   loaddata() async {
//     Map<String, String> map = new Map();
//     SharedPreferences pref = await SharedPreferences.getInstance();
//     // print(pref.getStringList('userinfo'));
//     map["id"] = pref.getString('uid');
//     if (type == 2) {
//       type = -1;
//     }
//     if (type == 3) {
//       type = 2;
//     }
//     map["type"] = type.toString();
//     print(map);

//     HttpHelper.post(HttpHelper.API_UserOrderList, (data) async {
//       if (data != null) {

//         //Toast.show(data["msg"],context);
//         print(data["info"].length.toString());
//         if (data["code"].toString() == "1") {
//           setState(() {
//             orders = data["info"];
//           });
//           //pref.setStringList('userinfo', data["info"]);

//         }
//       }
//     }, params: map);
//   }

//   @override
//   void dispose() {
//     super.dispose();
//     mTabController.dispose();
//   }

// //MediaQuery.of(context).size.height
//   Widget buildcontent() {
//     List<Widget> tiles = [];
//     Widget content;
//     if (orders.length == 0) {
//       tiles.add(Center(
//           child: Column(
//               crossAxisAlignment: CrossAxisAlignment.center,
//               mainAxisAlignment: MainAxisAlignment.center,
//               children: <Widget>[
//             Padding(
//                 padding: new EdgeInsets.fromLTRB(
//                     15, MediaQuery.of(context).size.height / 2 - 100, 15, 0),
//                 child: new Text('暂无订单数据'))
//           ])));
//     } else {
//       for (var i = 0; i < orders.length; i++) {
//         var order = orders[i];
//         tiles.add(Padding(
//             padding: new EdgeInsets.fromLTRB(15, 10, 15, 0),
//             child: Container(
//               decoration: new BoxDecoration(
//                 color: Colors.white,
//                 borderRadius: BorderRadius.all(Radius.circular(10.0)),
//               ),
//               child: Column(
//                 children: <Widget>[
//                   Padding(
//                     padding: new EdgeInsets.fromLTRB(20, 10, 20, 10),
//                     child: Row(
//                       children: <Widget>[
//                         Expanded(
//                             flex: 2,
//                             child: new Text(
//                               order["order_sn"],
//                               style: TextStyle(
//                                   color: Color.fromRGBO(51, 51, 51, 1),
//                                   fontSize: 13),
//                             )),
//                         Expanded(
//                           flex: 1,
//                           child: new Align(
//                               alignment: Alignment.centerRight,
//                               child: Container(
//                                   padding: new EdgeInsets.fromLTRB(5, 2, 5, 2),
//                                   color: Color.fromRGBO(27, 182, 251, 0.3),
//                                   child: new Text(
//                                     order["order_type"],
//                                     style: TextStyle(
//                                         color: Color.fromRGBO(27, 182, 251, 1),
//                                         fontSize: 12),
//                                   ))),
//                         )
//                       ],
//                     ),
//                   ),
//                   Padding(
//                     padding: new EdgeInsets.fromLTRB(20, 10, 20, 10),
//                     child: Row(
//                       children: <Widget>[
//                         Expanded(
//                             flex: 1,
//                             child: new Text(
//                               '联系电话',
//                               style: TextStyle(
//                                   fontSize: 12,
//                                   color: Color.fromRGBO(51, 51, 51, 1)),
//                             )),
//                         Expanded(
//                           flex: 1,
//                           child: new Align(
//                               alignment: Alignment.centerRight,
//                               child: Container(
//                                   child: new Text(
//                                 order["phone_num"],
//                                 style: TextStyle(
//                                     color: Color.fromRGBO(153, 153, 153, 1),
//                                     fontSize: 12),
//                               ))),
//                         )
//                       ],
//                     ),
//                   ),
//                   Padding(
//                     padding: new EdgeInsets.fromLTRB(20, 0, 20, 10),
//                     child: Row(
//                       children: <Widget>[
//                         Expanded(
//                             flex: 1,
//                             child: new Text(
//                               '预约时间',
//                               style: TextStyle(
//                                   fontSize: 12,
//                                   color: Color.fromRGBO(51, 51, 51, 1)),
//                             )),
//                         Expanded(
//                           flex: 1,
//                           child: new Align(
//                               alignment: Alignment.centerRight,
//                               child: Container(
//                                   child: new Text(
//                                 order['order_time'],
//                                 style: TextStyle(
//                                     color: Color.fromRGBO(153, 153, 153, 1),
//                                     fontSize: 12),
//                               ))),
//                         )
//                       ],
//                     ),
//                   ),
//                   Padding(
//                     padding: new EdgeInsets.fromLTRB(20, 0, 20, 10),
//                     child: Row(
//                       children: <Widget>[
//                         Expanded(
//                             flex: 1,
//                             child: new Text(
//                               '订单金额',
//                               style: TextStyle(
//                                   fontSize: 12,
//                                   color: Color.fromRGBO(51, 51, 51, 1)),
//                             )),
//                         Expanded(
//                           flex: 1,
//                           child: new Align(
//                               alignment: Alignment.centerRight,
//                               child: Container(
//                                   child: new Text(
//                                 '¥' + order['orderPrice'],
//                                 style: TextStyle(
//                                     color: Color.fromRGBO(251, 73, 57, 1),
//                                     fontSize: 12),
//                               ))),
//                         )
//                       ],
//                     ),
//                   ),
//                   Padding(
//                     padding: new EdgeInsets.fromLTRB(20, 0, 20, 10),
//                     child: Row(
//                       children: <Widget>[
//                         Expanded(
//                             flex: 1,
//                             child: new Text(
//                               '汽车品牌',
//                               style: TextStyle(
//                                   fontSize: 12,
//                                   color: Color.fromRGBO(51, 51, 51, 1)),
//                             )),
//                         Expanded(
//                           flex: 1,
//                           child: new Align(
//                               alignment: Alignment.centerRight,
//                               child: Container(
//                                   child: new Text(
//                                 order["brand_string"]["name"],
//                                 style: TextStyle(
//                                     color: Color.fromRGBO(153, 153, 153, 1),
//                                     fontSize: 12),
//                               ))),
//                         )
//                       ],
//                     ),
//                   ),
//                   Padding(
//                     padding: new EdgeInsets.fromLTRB(20, 10, 20, 10),
//                     child: Align(
//                         alignment: Alignment.centerRight,
//                         child: new Container(
//                           child: new Material(
//                             //INK可以实现装饰容器
//                             child: new Ink(
//                               //用ink圆角矩形
//                               // color: Colors.red,
//                               decoration: new BoxDecoration(
//                                 //背景
//                                 color: Colors.white,
//                                 //设置四周圆角 角度
//                                 borderRadius:
//                                     BorderRadius.all(Radius.circular(15.0)),
//                                 //设置四周边框
//                                 border: new Border.all(
//                                     width: 1,
//                                     color: Color.fromRGBO(27, 182, 251, 1)),
//                               ),
//                               child: new InkWell(
//                                   //圆角设置,给水波纹也设置同样的圆角
//                                   //如果这里不设置就会出现矩形的水波纹效果
//                                   borderRadius: new BorderRadius.circular(15.0),
//                                  // 设置点击事件回调
//                                   onTap: () {
//                                     Navigator.of(context).push(
//                                         new MaterialPageRoute(builder: (_) {
//                                       return new JIanceDetailPage(
//                                           order["id"].toString());
//                                     }));
//                                   },
//                                   child: Container(
//                                     //设置 child 居中
//                                     alignment: Alignment(0, 0),
//                                     height: 30,
//                                     width: 85,
//                                     child: Text(
//                                       "查看订单",
//                                       style: TextStyle(
//                                           color:
//                                               Color.fromRGBO(27, 182, 251, 1)),
//                                     ),
//                                   )),
//                             ),
//                           ),
//                         )
//                         // child: new RaisedButton(
//                         //   child: Text('申请补考'),
//                         //   onPressed: () {},
//                         // ),
//                         ),
//                   ),
//                 ],
//               ),
//             )));
//       }
//     }
//     content = new Column(
//         children: tiles //重点在这里，因为用编辑器写Column生成的children后面会跟一个<Widget>[]，
//         //此时如果我们直接把生成的tiles放在<Widget>[]中是会报一个类型不匹配的错误，把<Widget>[]删了就可以了
//         );
//     return content;
//   }
// }

// Widget buttons() {
//   Widget button = Container(
//     margin: EdgeInsets.only(left: 40, top: 40),
//     child: new Material(
//       //INK可以实现装饰容器
//       child: new Ink(
//         //用ink圆角矩形
//         // color: Colors.red,
//         decoration: new BoxDecoration(
//           //背景
//           color: Colors.white,
//           //设置四周圆角 角度
//           borderRadius: BorderRadius.all(Radius.circular(25.0)),
//           //设置四周边框
//           border: new Border.all(width: 1, color: Colors.red),
//         ),
//         child: new InkWell(
//             //圆角设置,给水波纹也设置同样的圆角
//             //如果这里不设置就会出现矩形的水波纹效果
//             borderRadius: new BorderRadius.circular(25.0),
//             //设置点击事件回调
//             onTap: () {},
//             child: Container(
//               //设置 child 居中
//               alignment: Alignment(0, 0),
//               height: 50,
//               width: 300,
//               child: Text("点击 Container 圆角边框"),
//             )),
//       ),
//     ),
//   );
//   return button;
// }

// class Choice {
//   const Choice({this.title, this.icon, this.position});
//   final String title;
//   final int position;
//   final IconData icon;
// }
